<template>
  <div>
    <el-dialog title="选择专业" :visible.sync="dialogVisible" :close-on-click-modal="false" width="55%"
      :before-close="handleClose()" :showClose="false">
      <div class="login_content">
        <div class="login_content_main">
          <div class="left_img">
            <img src="../assets/img_data.png" alt="">
          </div>
          <div class="right_main">
            <h3>专业选择</h3>
            <div class="select">
              <el-select v-model="majorvalue" placeholder="请选择专业" clearable>
              <el-option v-for="item in majorOptions" :key="item.id" :label="item.majorName" :value="item.id">
              </el-option>
            </el-select>
            </div>
            
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="change()">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { getAllMojorList } from "@/api/questmassage";
export default {
  data() {
    return {
      dialogVisible: false,
      majorvalue: '',
      majorOptions: [
        {
          id: "",
          majorName: "",
        },
      ],
    }
  },
  methods: {
    handleClose() { },
    change() {
      if (this.majorvalue == '') {
        this.$message.error('请选择专业')
        return false
      }
      localStorage.setItem('major', this.majorvalue);
      this.dialogVisible = false
      this.$router.push(
        { path: "/HomePage" }
      )
    },
  },
  mounted() {
    this.dialogVisible = true
    getAllMojorList().then((res) => {
      this.majorOptions = res.data.data
    })
  }
}
</script>
<style lang="scss" scoped>
.login_content_main {
  width: 800px;
  min-width: 600px;
  // margin: auto;
  height: 350px;
  // border: 1px solid red;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-evenly;

  .left_img {
    img {
      width: 300px;
      // border: 1px solid red;
      overflow-clip-margin: content-box;
      overflow: clip;
    }
  }
}

.login_content {
  // width: 1000px;
  height: 350px;
  // border: 1px solid red;
  display: flex;
  align-items: center;
  background-color: #F5FAFE;
  background-image: url(../assets/bg.png);
  background-repeat: no-repeat;
  background-position: bottom center;
}

.right_main {
  // right: 25%;
  width: 170px;
  height: 120px;
  background: #fff;
  bottom: 100px;
  padding: 25px 40px;
  border-radius: 5px;
  // display: flex;
  // align-items: center;
  .select{
   width: 150px;
   margin: 0 auto;
}
  h3 {
    font-size: 20px;
    color: #4BA4F8;
    text-align: center;
    margin: 0 0 20px 0;
    font-weight: 600;
    letter-spacing: 2px
  }
}
</style>